﻿namespace SupportSystemUI.Controls.Utility.Other
{
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// Interaction logic for ListItem.xaml
    /// </summary>
    public partial class ListItem : UserControl
    {
        /// <summary>
        /// The dependency property for the body text.
        /// </summary>
        public static readonly DependencyProperty BodyTextProperty = DependencyProperty.Register(
            "BodyText", typeof(string), typeof(ListItem), new UIPropertyMetadata(string.Empty));

        /// <summary>
        /// The dependency property for the title text.
        /// </summary>
        public static readonly DependencyProperty TitleTextProperty = DependencyProperty.Register(
            "TitleText", typeof(string), typeof(ListItem), new UIPropertyMetadata(string.Empty));
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ListItem"/> class.
        /// </summary>
        public ListItem()
        {
            this.InitializeComponent();
            this.Loaded += (sender, args) =>
            {
                this.titleBlock.Text = this.TitleText;
                this.bodyBlock.Text = this.BodyText;
            };
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ListItem"/> class.
        /// </summary>
        /// <param name="title">Title of this item.</param>
        /// <param name="body">Body of this item.</param>
        public ListItem(string title, string body)
        {
            this.InitializeComponent();
            this.titleBlock.Text = title;
            this.bodyBlock.Text = body;
        }

        /// <summary>
        /// Gets or sets the value of the title text.
        /// </summary>
        public string TitleText
        {
            get { return (string)this.GetValue(TitleTextProperty); }
            set { this.SetValue(TitleTextProperty, value); }
        }

        /// <summary>
        /// Gets or sets the value of the body text.
        /// </summary>
        public string BodyText
        {
            get { return (string)this.GetValue(BodyTextProperty); }
            set { this.SetValue(BodyTextProperty, value); }
        }
    }
}
